home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 22
/
Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso
/
Aminet
/
util
/
rexx
/
ElAssign.lha
/
ElAssign
/
ElAssign.REXX
< prev
Wrap
OS/2 REXX Batch file
|
1997-09-10
|
6KB
|
241 lines
/* Script which removes all assigns from a directory and all its
subdirectories and files and optionally deletes the directory with its
contents. $VER: ElAssign.REXX V1.1 (10.9.97) © Andrija Antonijevic
Written by Andrija Antonijevic <TheAntony@bigfoot.com>.
Many thanks to Charles Patterson <midian@azstarnet.com> whose
DeAssign.dopus5 gave me the idea to write my own version.
I made the following improvements:
- You don't need DOpus5 since it works with everything including
DOpus4, DOpus5 and any other kind of filemanager program.
- It will remove all assigns from a directory and all its subdirectories
and files unless NODEEP option is specified.
- Deleting chosen directory with all its contents is just an
option here. You can specify DELETE for deleting the directory
with confirmation and KILL for deleting without confirmation.
- You can give any kind of path to the directory/file: using
complete path, relative path or assign.
Version 1.1:
- Fixed a very dangerous bug caused by different treatment
of .info files in DOS. If .info file was passed as argument
to this script, it would eventually become the current directory!
So it was very dangerous if someone used KILL option and selected
icon file for deletion.
Requirements:
~~~~~~~~~~~~~
- rexxsupport.library (reqired)
- rexxreqtools.library - only if you specify DELETE option
(see below)
- Filemanager like DOpus4 or 5 will make things easier (optional ;))
Command line:
~~~~~~~~~~~~~
ElAssign.REXX NAME [DELETE | KILL] [NODEEP]
NAME is the name of the file/directory to remove the assigns from.
If NAME has spaces in it, it must be enclosed with double quotes.
DELETE deletes the directory but only if you confirm whilst
KILL is a silent killer ;) Default is not to delete anything.
DELETE will override KILL if you "accidentaly" put them both
into the command line.
NODEEP instructs the script only to remove assigns from the
argument you specified (file or directory) and not to go
deep in the jungles of the directory (you can't go into
the file, can you?).
Usage:
~~~~~~
From Shell:
[RX] FullPath:ToScript/ElAssign.REXX NAME [DELETE | KILL] [NODEEP]
DOpus4:
Configuration/Buttons:
+--------+
|AmigaDOS| RX FullPath:ToScript/ElAssign.REXX "{f}" [DELETE | KILL] [NODEEP]
+--------+
You might want to select "Do all files".
You can also set up a hotkey for the button.
DOpus5:
I don't have DOpus5 but it's fairly easy to set this script up
with it. Please consult your DOpus5 manual to see how to do it.
Looking at installation instructions for DOpus4 ({f} is file name
which should be enclosed with double quotes) might help.
Oh, yes. "El" in ElAssign doesn't have anything to do with Spain.
It's short from Eliminate :)
Finally, if you find any bugs or have some suggestions, please contact
me (Andrija Antonijevic <TheAntony@bigfoot.com>).
*/
QUOTE='22'x
LF='0A'x
TempAssign='T:AssignResult'
TempWhich='T:WhichResult'
TempCD='T:CDResult'
Quest='Do you really wish to delete'
DoDel=0
Deep=1
OPTIONS RESULTS
IF ~SHOW('L', 'rexxsupport.library') THEN IF ~ADDLIB('rexxsupport.library', 0, -30, 0) THEN DO
SAY "Couldn't open rexxsupport.library!"
EXIT(10)
END
PARSE ARG '"' Path '"' Temp Temp1 Temp2
IF Path='' & Temp='' & Temp1='' & Temp2='',
THEN PARSE ARG Path Temp Temp1 Temp2
IF ~(EXISTS(Path)) | Path='' THEN DO
SAY 'Invalid file/dir specified!'
EXIT
END
IF (UPPER(Temp)='KILL' | UPPER(Temp1)='KILL' | UPPER(Temp2)='KILL'),
THEN DoDel=2
IF (UPPER(Temp)='DELETE' | UPPER(Temp1)='DELETE' | UPPER(Temp2)='DELETE'),
THEN DoDel=1
IF (UPPER(Temp)='NODEEP' | UPPER(Temp1)='NODEEP' | UPPER(Temp2)='NODEEP'),
THEN Deep=0
IF DoDel=1 THEN IF ~SHOW('L','rexxreqtools.library') THEN IF ~ADDLIB('rexxreqtools.library',0,-30,0) THEN DO
SAY "Couldn't open rexxreqtools.library!"
EXIT(10)
END
InfoFlag=0
IF RIGHT(Path, 5)='.info' THEN DO
InfoFlag=1
PL=LENGTH(Path)
DO i=PL TO 1 BY -1
IF SUBSTR(Path, i, 1)=':' THEN BREAK
END
Colon=i
DO i=PL TO 1 BY -1
IF SUBSTR(Path, i, 1)='/' THEN BREAK
END
Slash=i
LastSpec=MAX(Colon, Slash)
Filename=RIGHT(Path, PL-LastSpec)
Path=LEFT(Path, LastSpec)
END
StorPath=Path
ADDRESS COMMAND 'Which 'QUOTE||Path||QUOTE' >'TempWhich
Suc=OPEN(FHWh, TempWhich, 'R')
IF Suc~=1 THEN DO
SAY "Couldn't open temporary file!"
EXIT(10)
END
Path=READLN(FHWh)
CLOSE(FHWh)
ADDRESS COMMAND 'Delete 'TempWhich' QUIET'
IF Path='' THEN DO
OldDir=PRAGMA('D', StorPath)
ADDRESS COMMAND 'CD >'TempCD
Suc=OPEN(FHCD, TempCD, 'R')
IF Suc~=1 THEN DO
SAY "Couldn't open temporary file!"
EXIT(10)
END
Path=READLN(FHCD)
CLOSE(FHCD)
ADDRESS COMMAND 'Delete 'TempCD' QUIET'
PRAGMA('D', OldDir)
END
IF Path='' THEN DO
SAY 'No file/dir supplied!'
EXIT(10)
END
IF InfoFlag=1 THEN DO
IF RIGHT(Path, 1)~=':' THEN Path=Path||'/'
Path=Path||Filename
END
Leny=LENGTH(Path)
Cntr=0
ADDRESS COMMAND 'Assign DIRS >'TempAssign
Suc=OPEN(FHAss, TempAssign, 'R')
IF Suc~=1 THEN DO
SAY "Couldn't open temporary file!"
EXIT(10)
END
Curr=0
Line=READLN(FHAss)
Line=READLN(FHAss)
DO WHILE ~EOF(FHAss)
Line=READLN(FHAss)
Prev=Curr
Curr=Curr+1
PARSE VAR Line Assign.Curr Dir.Curr
Dir.Curr=STRIP(Dir.Curr)
IF Assign.Curr="+" THEN Assign.Curr=Assign.Prev
IF (Dir.Curr=Path) | (Deep & ((LEFT(Dir.Curr, Leny)=Path & SUBSTR(Dir.Curr, Leny+1,1)='/'),
| (LEFT(Dir.Curr, Leny)=Path & SUBSTR(Dir.Curr, Leny+1,1)=':'))),
THEN DO
Cntr=Cntr+1
RemAssign.Cntr=Assign.Curr
RemName.Cntr=Dir.Curr
END
END
CLOSE(FHAss)
ADDRESS COMMAND 'Delete 'TempAssign' QUIET'
IF Cntr>0 THEN DO
DO I=1 to Cntr
ADDRESS COMMAND 'Assign 'RemAssign.I': 'QUOTE||RemName.I||QUOTE' REMOVE'
END
END
IF DoDel=1 THEN DO
RES=rtEZRequest(Quest||LF||LF||Path, '_Delete|_Cancel', 'ElAssign', 'rt_reqpos=reqpos_centerscr rtez_flags=ezreqf_centertext')
IF RES=0 THEN DoDel=0
END
IF DoDel~=0 THEN DO
ADDRESS COMMAND 'Delete 'QUOTE||Path||QUOTE' ALL FORCE QUIET'
END
EXIT